<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="简书,OS,bochs," />










<meta name="description" content="第一次写一个引导程序，还是记下来吧">
<meta property="og:type" content="article">
<meta property="og:title" content="写了个引导程序">
<meta property="og:url" content="http://wanazi.oschina.io/2018/05/27/写了个引导程序/index.html">
<meta property="og:site_name" content="wanazi">
<meta property="og:description" content="第一次写一个引导程序，还是记下来吧">
<meta property="og:image" content="http://wanazi.oschina.io/2018/05/27/写了个引导程序/output.png">
<meta property="og:updated_time" content="2019-02-27T12:39:26.432Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="写了个引导程序">
<meta name="twitter:description" content="第一次写一个引导程序，还是记下来吧">
<meta name="twitter:image" content="http://wanazi.oschina.io/2018/05/27/写了个引导程序/output.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://wanazi.oschina.io/2018/05/27/写了个引导程序/"/>





  <title>写了个引导程序 | wanazi</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">wanazi</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">偶尔记一些东西</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://wanazi.oschina.io/2018/05/27/写了个引导程序/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="tqd">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="wanazi">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">写了个引导程序</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-05-27T20:33:52+08:00">
                2018-05-27
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          
              <div class="post-description">
                  第一次写一个引导程序，还是记下来吧
              </div>
          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="&#x7F16;&#x5199;&#x5F15;&#x5BFC;&#x7A0B;&#x5E8F;&#x4EE3;&#x7801;"><a href="#&#x7F16;&#x5199;&#x5F15;&#x5BFC;&#x7A0B;&#x5E8F;&#x4EE3;&#x7801;" class="headerlink" title="&#x7F16;&#x5199;&#x5F15;&#x5BFC;&#x7A0B;&#x5E8F;&#x4EE3;&#x7801;"></a>&#x7F16;&#x5199;&#x5F15;&#x5BFC;&#x7A0B;&#x5E8F;&#x4EE3;&#x7801;</h2><p>&#x6587;&#x4EF6;&#x540D;&#x79F0;boot.s</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div></pre></td><td class="code"><pre><div class="line">.code16</div><div class="line">.section .data</div><div class="line">.section .text</div><div class="line">.global _start</div><div class="line">.equ BOOTSEG,0x07c0</div><div class="line">_start:</div><div class="line">ljmp $BOOTSEG,$go</div><div class="line">go:</div><div class="line">    movw %cs,%ax</div><div class="line">    movw %ax,%ds</div><div class="line">    movw %ax,%es</div><div class="line">    # movw $17,%di</div><div class="line">    # movb $0xa,%bl</div><div class="line">    # movw $msg1,%cx</div><div class="line">    # movb %bl,(%cx,%di,1)</div><div class="line">    movw $19,%cx</div><div class="line">    movw $0x1004,%dx</div><div class="line">    movw $0x000c,%bx</div><div class="line">    movw $msg1,%bp</div><div class="line">    movw $0x1301,%ax</div><div class="line">    int $0x10</div><div class="line">loop1:</div><div class="line">    jmp loop1</div><div class="line">msg1:</div><div class="line">    .ascii &quot;Loading system...&quot;</div><div class="line">    .byte 13,10</div><div class="line">    .org 510</div><div class="line">    .word 0xAA55</div></pre></td></tr></table></figure>
<p>&#x8FD9;&#x6BB5;&#x4EE3;&#x7801;&#x7684;&#x4F5C;&#x7528;&#x5C31;&#x662F;&#x5728;&#x5C4F;&#x5E55;&#x4E0A;&#x663E;&#x793A;Loading system&#x2026;,&#x7136;&#x540E;&#x8FDB;&#x5165;&#x6B7B;&#x5FAA;&#x73AF;</p>
<h2 id="&#x7F16;&#x8BD1;"><a href="#&#x7F16;&#x8BD1;" class="headerlink" title="&#x7F16;&#x8BD1;"></a>&#x7F16;&#x8BD1;</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">as boot.s -o boot.o   #32bit</div><div class="line">as --32 boot.s -o boot.o #64bit</div></pre></td></tr></table></figure>
<h2 id="&#x94FE;&#x63A5;"><a href="#&#x94FE;&#x63A5;" class="headerlink" title="&#x94FE;&#x63A5;"></a>&#x94FE;&#x63A5;</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">ld -Ttext 0x00 boot.o -o boot #32bit </div><div class="line">ld -m elf_i386 -Ttext 0x00 boot.o -o boot #64bit</div></pre></td></tr></table></figure>
<h2 id="&#x53BB;&#x6389;elf&#x5934;"><a href="#&#x53BB;&#x6389;elf&#x5934;" class="headerlink" title="&#x53BB;&#x6389;elf&#x5934;"></a>&#x53BB;&#x6389;elf&#x5934;</h2><p>&#x53BB;&#x6389;boot&#x6587;&#x4EF6;&#x7684;elf&#x6587;&#x4EF6;&#x5934;&#xFF0C;&#x4EE5;&#x53CA;&#x7B26;&#x53F7;&#x4FE1;&#x606F;&#xFF0C;&#x4F7F;&#x7528;java&#x4EE3;&#x7801;</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> com.tqd.elf.tool;</div><div class="line"></div><div class="line"><span class="keyword">import</span> java.io.File;</div><div class="line"><span class="keyword">import</span> java.io.IOException;</div><div class="line"><span class="keyword">import</span> java.nio.ByteBuffer;</div><div class="line"><span class="keyword">import</span> java.nio.channels.FileChannel;</div><div class="line"><span class="keyword">import</span> java.nio.file.Files;</div><div class="line"><span class="keyword">import</span> java.nio.file.StandardOpenOption;</div><div class="line"></div><div class="line"><span class="comment">/**</span></div><div class="line"> * Hello world!</div><div class="line"> *</div><div class="line"> */</div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">App</span> </span></div><div class="line">{</div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">( String[] args )</span> <span class="keyword">throws</span> IOException</span></div><div class="line">    {</div><div class="line">        File file=<span class="keyword">new</span> File(<span class="string">&quot;/disk_data/code/git/AsmCode/OS/boot&quot;</span>);</div><div class="line">        File outfile=<span class="keyword">new</span> File(<span class="string">&quot;/disk_data/code/git/AsmCode/OS/boot.bin&quot;</span>);</div><div class="line">        <span class="keyword">byte</span>[] data=Files.readAllBytes(file.toPath());</div><div class="line">        </div><div class="line">        <span class="keyword">byte</span> end0=<span class="number">0x55</span>;</div><div class="line">        <span class="keyword">byte</span> end1= (<span class="keyword">byte</span>)<span class="number">0xaa</span>;</div><div class="line">        <span class="keyword">int</span> foundIndex=-<span class="number">1</span>;</div><div class="line">        <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;data.length;i++) {</div><div class="line">        	<span class="keyword">if</span>(i%<span class="number">16</span>==<span class="number">0</span>) {</div><div class="line">        		System.out.println(<span class="string">&quot;&quot;</span>);</div><div class="line">        	}</div><div class="line">        	String hex=Integer.toHexString(data[i]&amp;<span class="number">0xff</span>);</div><div class="line">        	String s=String.format(<span class="string">&quot;%2s&quot;</span>, hex);</div><div class="line">        	System.out.printf(<span class="string">&quot;|%s|&quot;</span>, s);</div><div class="line">        	<span class="keyword">if</span>(i&gt;<span class="number">0</span>) {</div><div class="line">        		<span class="keyword">if</span>(data[i]==end1 &amp;&amp; data[i-<span class="number">1</span>]==end0) {</div><div class="line">        			foundIndex=i;</div><div class="line">        			<span class="keyword">break</span>;</div><div class="line">        		}</div><div class="line">        	}</div><div class="line">        }</div><div class="line">        System.out.println(<span class="string">&quot;&quot;</span>);</div><div class="line">        System.out.println(foundIndex);</div><div class="line">        <span class="keyword">int</span> startIndex=foundIndex-<span class="number">511</span>;</div><div class="line">        <span class="keyword">byte</span> ddd[]=<span class="keyword">new</span> <span class="keyword">byte</span>[<span class="number">512</span>];</div><div class="line">        System.arraycopy(data, startIndex, ddd, <span class="number">0</span>, <span class="number">512</span>);</div><div class="line">        </div><div class="line">        <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;ddd.length;i++) {</div><div class="line">        	<span class="keyword">if</span>(i%<span class="number">16</span>==<span class="number">0</span>) {</div><div class="line">        		System.out.println(<span class="string">&quot;&quot;</span>);</div><div class="line">        	}</div><div class="line">        	String hex=Integer.toHexString(ddd[i]&amp;<span class="number">0xff</span>);</div><div class="line">        	String s=String.format(<span class="string">&quot;%2s&quot;</span>, hex);</div><div class="line">        	System.out.printf(<span class="string">&quot;|%s|&quot;</span>, s);</div><div class="line">        }</div><div class="line">        </div><div class="line">        Files.write(outfile.toPath(), ddd, StandardOpenOption.CREATE);</div><div class="line">    }</div><div class="line">}</div></pre></td></tr></table></figure>
<p>&#x6267;&#x884C;&#x4EE3;&#x7801;&#x540E;&#x5F97;&#x5230;boot.bin&#x6587;&#x4EF6;</p>
<h2 id="&#x521B;&#x5EFA;&#x542F;&#x52A8;&#x8F6F;&#x76D8;&#x6587;&#x4EF6;"><a href="#&#x521B;&#x5EFA;&#x542F;&#x52A8;&#x8F6F;&#x76D8;&#x6587;&#x4EF6;" class="headerlink" title="&#x521B;&#x5EFA;&#x542F;&#x52A8;&#x8F6F;&#x76D8;&#x6587;&#x4EF6;"></a>&#x521B;&#x5EFA;&#x542F;&#x52A8;&#x8F6F;&#x76D8;&#x6587;&#x4EF6;</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div></pre></td><td class="code"><pre><div class="line">wanazi@wanazi-PC:~/Documents$ bximage</div><div class="line">========================================================================</div><div class="line">                                bximage</div><div class="line">  Disk Image Creation / Conversion / Resize and Commit Tool for Bochs</div><div class="line">         $Id: bximage.cc 13069 2017-02-12 16:51:52Z vruppert $</div><div class="line">========================================================================</div><div class="line"></div><div class="line">1. Create new floppy or hard disk image</div><div class="line">2. Convert hard disk image to other format (mode)</div><div class="line">3. Resize hard disk image</div><div class="line">4. Commit &apos;undoable&apos; redolog to base image</div><div class="line">5. Disk image info</div><div class="line"></div><div class="line">0. Quit</div><div class="line"></div><div class="line">Please choose one [0] 1</div><div class="line"></div><div class="line">Create image</div><div class="line"></div><div class="line">Do you want to create a floppy disk image or a hard disk image?</div><div class="line">Please type hd or fd. [hd] fd</div><div class="line"></div><div class="line">Choose the size of floppy disk image to create.</div><div class="line">Please type 160k, 180k, 320k, 360k, 720k, 1.2M, 1.44M, 1.68M, 1.72M, or 2.88M.</div><div class="line"> [1.44M] 1.44M</div><div class="line"></div><div class="line">What should be the name of the image?</div><div class="line">[a.img] a.img</div><div class="line"></div><div class="line">Creating floppy image &apos;a.img&apos; with 2880 sectors</div><div class="line"></div><div class="line">The following line should appear in your bochsrc:</div><div class="line">  floppya: image=&quot;a.img&quot;, status=inserted</div></pre></td></tr></table></figure>
<p>&#x5C06;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;boot.bin&#x5199;&#x5165;&#x8F6F;&#x76D8;</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">dd if=boot.bin of=a.img bs=512 count=1 conv=notrunc</div></pre></td></tr></table></figure>
<h2 id="&#x7F16;&#x5199;bochsrc&#x914D;&#x7F6E;&#x6587;&#x4EF6;"><a href="#&#x7F16;&#x5199;bochsrc&#x914D;&#x7F6E;&#x6587;&#x4EF6;" class="headerlink" title="&#x7F16;&#x5199;bochsrc&#x914D;&#x7F6E;&#x6587;&#x4EF6;"></a>&#x7F16;&#x5199;bochsrc&#x914D;&#x7F6E;&#x6587;&#x4EF6;</h2><figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">megs:32</div><div class="line">romimage:file=/home/wanazi/Documents/bochs-2.6.9/bios/BIOS-bochs-latest</div><div class="line">vgaromimage:file=/home/wanazi/Documents/bochs-2.6.9/bios/VGABIOS-lgpl-latest</div><div class="line">floppya:1_44=a.img,status=inserted</div><div class="line">boot:floppy</div><div class="line">log:bochsout.text</div><div class="line">mouse:enabled=0</div><div class="line">keyboard:type=mf, serial_delay=200, paste_delay=100000</div></pre></td></tr></table></figure>
<h2 id="&#x542F;&#x52A8;bochs"><a href="#&#x542F;&#x52A8;bochs" class="headerlink" title="&#x542F;&#x52A8;bochs"></a>&#x542F;&#x52A8;bochs</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div></pre></td><td class="code"><pre><div class="line">wanazi@wanazi-PC:/disk_data/code/git/AsmCode/OS$ bochs -f bochsrc</div><div class="line">========================================================================</div><div class="line">                       Bochs x86 Emulator 2.6.9</div><div class="line">               Built from SVN snapshot on April 9, 2017</div><div class="line">                  Compiled on Nov 28 2017 at 20:28:07</div><div class="line">========================================================================</div><div class="line">00000000000i[      ] BXSHARE not set. using compile time default &apos;/usr/local/share/bochs&apos;</div><div class="line">00000000000i[      ] reading configuration from bochsrc</div><div class="line">------------------------------</div><div class="line">Bochs Configuration: Main Menu</div><div class="line">------------------------------</div><div class="line"></div><div class="line">This is the Bochs Configuration Interface, where you can describe the</div><div class="line">machine that you want to simulate.  Bochs has already searched for a</div><div class="line">configuration file (typically called bochsrc.txt) and loaded it if it</div><div class="line">could be found.  When you are satisfied with the configuration, go</div><div class="line">ahead and start the simulation.</div><div class="line"></div><div class="line">You can also start bochs with the -q option to skip these menus.</div><div class="line"></div><div class="line">1. Restore factory default configuration</div><div class="line">2. Read options from...</div><div class="line">3. Edit options</div><div class="line">4. Save options to...</div><div class="line">5. Restore the Bochs state from...</div><div class="line">6. Begin simulation</div><div class="line">7. Quit now</div><div class="line"></div><div class="line">Please choose one: [6] 6</div><div class="line">00000000000i[      ] installing x module as the Bochs GUI</div><div class="line">00000000000i[      ] using log file bochsout.text</div><div class="line">Next at t=0</div><div class="line">(0) [0x0000fffffff0] f000:fff0 (unk. ctxt): jmpf 0xf000:e05b  ; ea5be000f0</div><div class="line">&lt;bochs:1&gt; b 0x7c00</div><div class="line">&lt;bochs:2&gt; c</div><div class="line">(0) Breakpoint 1, 0x00007c00 in ?? ()</div><div class="line">Next at t=14040237</div><div class="line">(0) [0x000000007c00] 0000:7c00 (unk. ctxt): jmpf 0x07c0:0005  ; ea0500c007</div><div class="line">&lt;bochs:3&gt; n</div><div class="line">Next at t=14040238</div><div class="line">(0) [0x000000007c05] 07c0:0005 (unk. ctxt): mov ax, cs  ; 8cc8</div><div class="line">&lt;bochs:4&gt; n</div><div class="line">Next at t=14040239</div><div class="line">(0) [0x000000007c07] 07c0:0007 (unk. ctxt): mov ds, ax  ; 8ed8</div><div class="line">&lt;bochs:5&gt; n</div><div class="line">Next at t=14040240</div><div class="line">(0) [0x000000007c09] 07c0:0009 (unk. ctxt): mov es, ax  ; 8ec0</div><div class="line">&lt;bochs:6&gt; n</div><div class="line">Next at t=14040241</div><div class="line">(0) [0x000000007c0b] 07c0:000b (unk. ctxt): mov cx, 0x0013  ; b91300</div><div class="line">&lt;bochs:7&gt; n</div><div class="line">Next at t=14040242</div><div class="line">(0) [0x000000007c0e] 07c0:000e (unk. ctxt): mov dx, 0x1004  ; ba0410</div><div class="line">&lt;bochs:8&gt; n</div><div class="line">Next at t=14040243</div><div class="line">(0) [0x000000007c11] 07c0:0011 (unk. ctxt): mov bx, 0x000c  ; bb0c00</div><div class="line">&lt;bochs:9&gt; n</div><div class="line">Next at t=14040244</div><div class="line">(0) [0x000000007c14] 07c0:0014 (unk. ctxt): mov bp, 0x001e  ; bd1e00</div><div class="line">&lt;bochs:10&gt; n</div><div class="line">Next at t=14040245</div><div class="line">(0) [0x000000007c17] 07c0:0017 (unk. ctxt): mov ax, 0x1301  ; b80113</div><div class="line">&lt;bochs:11&gt; n</div><div class="line">Next at t=14040246</div><div class="line">(0) [0x000000007c1a] 07c0:001a (unk. ctxt): int 0x10  ; cd10</div><div class="line">&lt;bochs:12&gt; n</div><div class="line">Next at t=14053700</div><div class="line">(0) [0x000000007c1c] 07c0:001c (unk. ctxt): jmp .-2 (0x00007c1c)  ; ebfe</div><div class="line">&lt;bochs:13&gt; n</div><div class="line">Next at t=14053701</div><div class="line">(0) [0x000000007c1c] 07c0:001c (unk. ctxt): jmp .-2 (0x00007c1c)  ; ebfe</div><div class="line">&lt;bochs:14&gt; n</div><div class="line">Next at t=14053702</div><div class="line">(0) [0x000000007c1c] 07c0:001c (unk. ctxt): jmp .-2 (0x00007c1c)  ; ebfe</div><div class="line">&lt;bochs:15&gt; n</div><div class="line">Next at t=14053703</div><div class="line">(0) [0x000000007c1c] 07c0:001c (unk. ctxt): jmp .-2 (0x00007c1c)  ; ebfe</div><div class="line">&lt;bochs:16&gt; n</div><div class="line">Next at t=14053704</div><div class="line">(0) [0x000000007c1c] 07c0:001c (unk. ctxt): jmp .-2 (0x00007c1c)  ; ebfe</div><div class="line">&lt;bochs:17&gt; n</div><div class="line">Next at t=14053705</div><div class="line">(0) [0x000000007c1c] 07c0:001c (unk. ctxt): jmp .-2 (0x00007c1c)  ; ebfe</div><div class="line">&lt;bochs:18&gt; n</div><div class="line">Next at t=14053706</div><div class="line">(0) [0x000000007c1c] 07c0:001c (unk. ctxt): jmp .-2 (0x00007c1c)  ; ebfe</div><div class="line">&lt;bochs:19&gt;</div></pre></td></tr></table></figure>
<h2 id="&#x8FD0;&#x884C;&#x7ED3;&#x679C;"><a href="#&#x8FD0;&#x884C;&#x7ED3;&#x679C;" class="headerlink" title="&#x8FD0;&#x884C;&#x7ED3;&#x679C;"></a>&#x8FD0;&#x884C;&#x7ED3;&#x679C;</h2><p><img src="/2018/05/27/&#x5199;&#x4E86;&#x4E2A;&#x5F15;&#x5BFC;&#x7A0B;&#x5E8F;/output.png" alt="boot.png"></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/简书/" rel="tag"># 简书</a>
          
            <a href="/tags/OS/" rel="tag"># OS</a>
          
            <a href="/tags/bochs/" rel="tag"># bochs</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/04/29/我们歪着说话/" rel="next" title="我们歪着说话">
                <i class="fa fa-chevron-left"></i> 我们歪着说话
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/10/19/2018-10-19/" rel="prev" title="唐·柳宗元《读韩愈所著毛颖传后题》">
                唐·柳宗元《读韩愈所著毛颖传后题》 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">tqd</p>
              <p class="site-description motion-element" itemprop="description">只是为了好玩</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">19</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">28</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#编写引导程序代码"><span class="nav-number">1.</span> <span class="nav-text">编写引导程序代码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#编译"><span class="nav-number">2.</span> <span class="nav-text">编译</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#链接"><span class="nav-number">3.</span> <span class="nav-text">链接</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#去掉elf头"><span class="nav-number">4.</span> <span class="nav-text">去掉elf头</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#创建启动软盘文件"><span class="nav-number">5.</span> <span class="nav-text">创建启动软盘文件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#编写bochsrc配置文件"><span class="nav-number">6.</span> <span class="nav-text">编写bochsrc配置文件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#启动bochs"><span class="nav-number">7.</span> <span class="nav-text">启动bochs</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#运行结果"><span class="nav-number">8.</span> <span class="nav-text">运行结果</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">tqd</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
